const Host = "https://app.vmovier.com/apiv3";
const http = function(url="",data={},method="GET"){
  return new Promise((resolve,reject)=>{
    wx.showLoading({
      title: '正在加载中···',
    })
    wx.request({
      url: Host+url,
      method,
      data,
      success:(res)=>{
        wx.hideLoading()
        if(res.data){
          if (res.data.data) {
            resolve(res.data.data);
            return;
          }
          resolve(res.data);
          return;
        }
        resolve(res);
      },
      fail:(err)=>{
        reject(err)
      }
    })
  })
}
const get= function (url="",data={}) {
  return http(url,data,"GET")
}

const post = function (url="",data={}) {
  return http(url,data,"POST")
}

module.exports={
  http,
  get,
  post
}